import { defineMock } from "../mock/base";

import { http } from '@/utils/http'
// 生成随机图片URL
const generateRandomImage = () => {
  const images = [
    "https://img1.baidu.com/it/u=194350191,3533239140&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500"
  ]
  return images[Math.floor(Math.random() * images.length)]
}

// 生成随机标题
const generateRandomTitle = () => {
  const brands = ["新西兰爱他美", "惠氏启赋A2", "美赞臣", "雀巢", "雅培", "飞鹤", "伊利", "君乐宝"]
  const types = ["奶粉", "配方奶", "有机奶", "羊奶粉", "水解蛋白奶粉"]
  return `${brands[Math.floor(Math.random() * brands.length)]}${types[Math.floor(Math.random() * types.length)]}`
}

// 生成随机描述
const generateRandomDescription = () => {
  const descriptions = [
    "这里展示品牌上榜理由配方温和营养均衡宝方温和营养均衡宝喝不上火配方适…",
    "采用先进工艺，保留更多营养，宝宝更易吸收，采用先进工艺，保留更多营养，宝宝更易吸收，采用先进工艺，保留更多营养，宝宝更易吸收，",
    "特别添加益生菌，帮助宝宝建立健康肠道环境，采用先进工艺，保留更多营养，宝宝更易吸收，采用先进工艺，保留更多营养，宝宝更易吸收，",
    "科学配比，营养全面，助力宝宝健康成长，采用先进工艺，保留更多营养，宝宝更易吸收，采用先进工艺，保留更多营养，宝宝更易吸收，",
    "精选优质奶源，严格把控品质，让妈妈更放心采用先进工艺，保留更多营养，宝宝更易吸收，采用先进工艺，保留更多营养，宝宝更易吸收，采用先进工艺，保留更多营养，宝宝更易吸收，"
  ]
  return descriptions[Math.floor(Math.random() * descriptions.length)]
}

// 生成随机人气值
const generateRandomHot = () => {
  return Math.floor(Math.random() * 10000) + 5000
}

// 生成随机数据
const generateRandomData = (count: number) => {
  return Array.from({ length: count }, (_, index) => ({
    id: index + 1,
    img: generateRandomImage(),
    title: generateRandomTitle(),
    hot: generateRandomHot(),
    description: generateRandomDescription()
  }))
}

//生成请求数据 
export const getBannerDataList = () => {
  return new Promise((resolve, reject) => {
    resolve(generateRandomData(1000))
  })
}
export default defineMock([
  {
    url: "banner/list",
    method: 'GET'
    body: ({ params }) => {
      code: 0,
        result: {
        
      },
    msg: "一切ok",

  }
  }
]);
